package com.c8a.validation.entity;

import com.c8a.validation.utils.EmployeeGroupSequenceProvider;
import lombok.Data;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.*;

/**
 * @Author C8A
 * @Date 2022-04-24 18:32
 * @Email 1912327276@qq.com
 */
@Data
@GroupSequenceProvider(EmployeeGroupSequenceProvider.class)
public class GroupEmployee {

    public interface Add {
    }

    public interface Edit {
    }

    public interface TitleJunior {
    }

    public interface TitleMiddle {
    }

    /**
     * @Null(groups = {Add.class}) //添加的时候生效
     * @NotNull(groups = {Edit.class}) //修改的时候生效
     */
    @NotNull(groups = {Add.class}, message = "id不能为空")
    private Integer id;

    @NotNull(groups = {Edit.class}, message = "age不能为空")
    private Integer age;

    @NotEmpty(message = "title不能为空")
    @Pattern(regexp = "^\u521d\u7ea7.*", groups = TitleJunior.class)        //初级
    @Pattern(regexp = "^\u4e2d\u7ea7.*", groups = TitleMiddle.class)           //中级
    private String title;


}
